package com.homework.action;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.homework.bean.CourseBean;
import com.homework.bean.PageInfoBean;
import com.homework.bean.UserResourceListBean;
import com.homework.service.ResourceService;

public class ResourceShowAction {

	private static ResourceService resourceService;
	private int courseId;
	private int intPage;

	public ResourceShowAction() {
		resourceService = new ResourceService();
	}

	public int getIntPage() {
		return intPage;
	}

	public void setIntPage(int intPage) {
		this.intPage = intPage;
	}

	public int getCourseId() {
		return courseId;
	}

	public void setCourseId(int courseId) {
		this.courseId = courseId;
	}

	// 资源列表
	public String resourceShow() throws SQLException {

		HttpServletRequest request = ServletActionContext.getRequest();

		// courseBean
		CourseBean courseBean = new CourseBean();
		courseBean.setCourseId(String.valueOf(this.getCourseId()));
		// pageInfoBean
		PageInfoBean pageInfoBean = new PageInfoBean();
		pageInfoBean.setIntPage(this.getIntPage());
		// courseId
		int courseIdTemp = this.getCourseId();

		// 处理和设置pageInfoBean,StudentHomeworkListBean
		UserResourceListBean userResourceListBean = new UserResourceListBean();
		userResourceListBean = resourceService.resourceShow(courseBean, pageInfoBean);
		request.setAttribute("userResourceListBean", userResourceListBean);
		request.setAttribute("pageInfoBean", pageInfoBean);
		request.setAttribute("courseId", courseIdTemp);

		return "Success";
	}

}
